"""指定路径2列文件读为字典{}
举例：
dataset_name=''
file_ent = 'data/{dataset_name}/kg/wd_id2entity_text.txt'.format(
        dataset_name=dataset_name
    )
e = readDict(file_ent)
"""
def readDict(filename):
    f = open(filename, 'r', encoding='utf-8')
    d = {}
    for line in f:
        line = line.strip().split('\t')
        if len(line) == 1:
            line.append('')  # in case literal was blank or whitespace
        d[line[0]] = line[1]
    f.close()
    return d